<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #wrapper{
            position: relative;
            width: 200px;
            height: 200px;
            border: 1px solid black;
            overflow: auto;
        }

        #first{
            position: fixed;
            bottom: 0;
            width: 100%;
            background-color: red;
        }
    </style>
</head>
<body>
    <div id="wrapper">
        <div id="first">hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        <div>hello world</div>
        </div>
        <script>
            window.onload = () => {
                const getScrollSize = ele => {
                    // ele为产生滚动条的元素
                    return ele.offsetWidth - ele.clientWidth
                }
                const wrapper = document.getElementById("wrapper")
                const firstEle = document.getElementById("first")
                console.log(firstEle.offsetParent);
                wrapper.onscroll = () => {
                    console.log(wrapper.style.position.top);
                    console.log(firstEle.style);
                }
                console.log(getScrollSize(wrapper));
                console.log(document.querySelector("#wrapper:first-child"));
            }

        </script>
</body>
</html>